package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.BoneCheckAdmin;
import com.ruoyi.service.IBoneCheckAdminService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 骨密度检查Controller
 * 
 * @author xiaohe
 * @date 2023-11-10
 */
@RestController
@RequestMapping("/ray/checklist")
public class BoneCheckAdminController extends BaseController
{
    @Autowired
    private IBoneCheckAdminService boneCheckAdminService;

    /**
     * 查询骨密度检查列表
     */
    @PreAuthorize("@ss.hasPermi('ray:checklist:list')")
    @GetMapping("/list")
    public TableDataInfo list(BoneCheckAdmin boneCheckAdmin)
    {
        startPage();
        List<BoneCheckAdmin> list = boneCheckAdminService.selectBoneCheckAdminList(boneCheckAdmin);
        return getDataTable(list);
    }

    /**
     * 导出骨密度检查列表
     */
    @PreAuthorize("@ss.hasPermi('ray:checklist:export')")
    @Log(title = "骨密度检查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoneCheckAdmin boneCheckAdmin)
    {
        List<BoneCheckAdmin> list = boneCheckAdminService.selectBoneCheckAdminList(boneCheckAdmin);
        ExcelUtil<BoneCheckAdmin> util = new ExcelUtil<BoneCheckAdmin>(BoneCheckAdmin.class);
        util.exportExcel(response, list, "骨密度检查数据");
    }

    /**
     * 获取骨密度检查详细信息
     */
    @PreAuthorize("@ss.hasPermi('ray:checklist:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(boneCheckAdminService.selectBoneCheckAdminById(id));
    }

    /**
     * 新增骨密度检查
     */
    @PreAuthorize("@ss.hasPermi('ray:checklist:add')")
    @Log(title = "骨密度检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoneCheckAdmin boneCheckAdmin)
    {
        return toAjax(boneCheckAdminService.insertBoneCheckAdmin(boneCheckAdmin));
    }

    /**
     * 修改骨密度检查
     */
    @PreAuthorize("@ss.hasPermi('ray:checklist:edit')")
    @Log(title = "骨密度检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoneCheckAdmin boneCheckAdmin)
    {
        return toAjax(boneCheckAdminService.updateBoneCheckAdmin(boneCheckAdmin));
    }

    /**
     * 删除骨密度检查
     */
    @PreAuthorize("@ss.hasPermi('ray:checklist:remove')")
    @Log(title = "骨密度检查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(boneCheckAdminService.deleteBoneCheckAdminByIds(ids));
    }
}
